package com.cmcc.qx.ws.controller;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.cmcc.qx.common.entity.ObjectType;
import com.cmcc.qx.ws.service.BackService;

@Controller
public class HomeSetController {
	
	@Resource(name = "BackServiceImpl")
	private BackService backService;

	@RequestMapping(value = "/back/nav.do", method = RequestMethod.GET)
	public String queryNav(HttpServletRequest request, HttpServletResponse response) throws IOException {
		List<ObjectType> navs = backService.queryNav();
		request.setAttribute("navs", navs);
		return "/back/npage/nav.jsp";
	}
	
	@RequestMapping(value="/back/updateNav.do", method = RequestMethod.GET)
	public void updateNav(HttpServletRequest request, HttpServletResponse response) throws IOException {
		ObjectType objType = backService.queryNavById(request.getParameter("id")+"");
		objType.setObjNum(Integer.valueOf(request.getParameter("objNum")+""));
		objType.setObjName(request.getParameter("objName").toString());
		objType.setSeq(Integer.valueOf(request.getParameter("seq")+""));
		backService.updateNav(objType);
	}
}
